#ifndef Q2HX711_h
#define Q2HX711_h

#include "Arduino.h"
#include <vector>

using u16 = unsigned short;

class Q2HX711 {
private:
#ifdef USE_FREERTOS

    static void thread(const void *);

    [[noreturn]] void rtos_loop();

#endif

    bool readyToSend();

public:
    Q2HX711(byte output_pin, byte clock_pin);

    virtual ~Q2HX711() = default;

    void begin();

    void setGain(byte gain = 128);

    long read();

    void reset();

    byte CLOCK_PIN;
    byte OUT_PIN;
    byte GAIN, next_gain;
    bool pinsConfigured;
    uint32_t last_tick;
    std::vector<int> da_buf;
    std::vector<int> db_buf;
    int da, db;
    byte count;
    u16 nrs = 10;
};

#endif /* Q2HX711_h */
